<!DOCTYPE html>
<meta charset="utf-8" />

<link rel="stylesheet" href="ace_v1.3/assets/css/ui.jqgrid.css" />
<link rel="stylesheet" href="ace_v1.3/assets/css/ace.css" class="ace-main-stylesheet" id="main-ace-style" />
		


<div class="search_panel">
<form action="mpamng/agent/queryAgent.do" method="post" onsubmit="return pageSearch(this);">
		<div class="widget-main">
			<div class="rowt">
				<div class="col-sm-12">
					<div>
						<div class="search_elm" style="margin-left: 0px">
							<label class="label_search">合作商ID:</label>
							<div class="search_input">
								<input id="agentId" type="text" name="agentId" placeholder="请输入合作商ID"/>
							</div>
						</div>
						<div class="search_elm" style="margin-left: 0px">
							<label class="label_search">登陆账户:</label>
							<div class="search_input">
								<input id="logonName" type="text" name="logonName" placeholder="请输入合作商登陆账户"/>
							</div>
						</div>
						<div class="search_elm" style="margin-left: 0px">
							<label class="label_search">合作商名称:</label>
							<div class="search_input">
								<input id="agentName" type="text" name="agentName" placeholder="合作商名称"/>
							</div>
						</div>
						<div class="search_elm" style="margin-left: 0px">
							<label class="label_search">法人姓名:</label>
							<div class="search_input">
								<input id="legalName" type="text" name="legalName" placeholder="请输入法人姓名"/>
							</div>
						</div>
						<div class="search_elm">
							<button class="btn btn-small btn_search" type="submit" title="搜索" > 搜索 </button>
						</div>
					</div>
				</div>
			</div>
		</div>
	</form>
</div>
	<div class="rowt">
		<div class="col-xs-12">
			<table id="grid-table"></table>
			<div id="grid-pager"></div>
			<div style="margin-top: 10px">
				 <span id="paging_bar" style="float: right"> </span>
			</div>

			<!-- PAGE CONTENT ENDS -->
		</div>
		<!-- /.col -->
	</div>
	<!-- /.row -->

	<!-- page specific plugin scripts -->
	<script type="text/javascript">
		var jqGrid;
		jQuery(function($) {
			var grid_selector = "#grid-table";
			var pager_selector = "#grid-pager";

			$(window).on(
					'resize.jqGrid',
					function() {
						$(grid_selector).jqGrid('setGridWidth',
								$(".page-content").width());
					})
			var parent_column = $(grid_selector).closest('[class*="col-"]');
			$(document).on(
					'settings.ace.jqGrid',
					function(ev, event_name, collapsed) {
						if (event_name === 'sidebar_collapsed'
								|| event_name === 'main_container_fixed') {
							setTimeout(function() {
								$(grid_selector).jqGrid('setGridWidth',
										parent_column.width());
							}, 0);
						}
					})
			jQuery(grid_selector).jqGrid({
				url : "mpamng/agent/queryAgent.do",
				datatype : "json",
				height : '100%',
				width : '90%',
				colNames : [ '合作商编号', '合作商登陆账号', '合作商名称','法人姓名 ','父合作商编号','一级合作商编号','合作商状态', '','','','','','',''],
				colModel : [ 
				             {name : 'agentId',           index : 'agentId',          width : '150px',sortable:false},
				             {name : 'logonName',         index : 'logonName',        width : '150px',sortable:false},
				             {name : 'agentName',         index : 'agentName',        width : '120px',sortable:false},
				             {name : 'legalName',         index : 'legalName',        width : '120px',sortable:false},
				             {name : 'fathAgentId',		  index : 'fathAgentId',      width : '150px',sortable:false}, 
				             {name : 'firstAgentId',      index : 'firstAgentId',     width : '150px',sortable:false}, 
				             {name : 'agentStatus',       index : 'agentStatus',      width : '120px', ditcKey:'AGENTSTATUS', formatter : gridFormatByDict,sortable:false },
				             {name : 'rateLivelihood',    index : 'rateLivelihood',   width : '0px' ,hidden : true,sortable:false},
				             {name : 'rateGeneral',       index : 'rateGeneral',      width : '0px' ,hidden : true,sortable:false},
				             {name : 'rateGeneralTop',    index : 'rateGeneralTop',   width : '0px' ,hidden : true,sortable:false},
				             {name : 'rateGeneralMaximun',    index : 'rateGeneralMaximun',   width : '0px' ,hidden : true,sortable:false},
				             {name : 'rateEntertain',     index : 'rateEntertain',    width : '0px' ,hidden : true,sortable:false},
				             {name : 'rateEntertainTop',  index : 'rateEntertainTop', width : '0px' ,hidden : true,sortable:false},
				             {name : 'rateEntertainMaximun',    index : 'rateEntertainMaximun',   width : '0px' ,hidden : true,sortable:false}
				            ],
				viewrecords : true,
				rowNum : 10,
				rowList : [ 10, 20, 30 ],
				altRows : true,
				shrinkToFit:false,
				multiselect : true,//设置行可多选的 
				multiboxonly : true,//
				sortable:false,
				ondblClickRow: function(){  
					setSelectAgent();
				},
				loadComplete : function() {
					var table = this;
					setTimeout(function() {
						//加载分页
						initPagingBar(grid_selector);
					}, 0);
				},
				beforeRequest : function() {//请求之前执行
					jqGrid = this;
				},
			});
			$(window).triggerHandler('resize.jqGrid');

			$(document).one('ajaxloadstart.page', function(e) {
				$(grid_selector).jqGrid('GridUnload');
				$('.ui-jqdialog').remove();
			});
		});
		//选中合作商
		function setSelectAgent() {
			var rows = $('#grid-table').jqGrid("getGridParam", "selarrrow");
			if (rows.length == 0 || rows.length > 1) {
				msg.alert("警告", "请选择一个合作商！", "warn");
				return false;
			}
			var agentId = $('#grid-table').jqGrid('getRowData',rows[0]).agentId;
			var agentName = $('#grid-table').jqGrid('getRowData',rows[0]).agentName;
			var rateLivelihood = $('#grid-table').jqGrid('getRowData',rows[0]).rateLivelihood;
			var rateGeneral = $('#grid-table').jqGrid('getRowData',rows[0]).rateGeneral;
			var rateGeneralTop = $('#grid-table').jqGrid('getRowData',rows[0]).rateGeneralTop;
			var rateGeneralMaximun=$('#grid-table').jqGrid('getRowData',rows[0]).rateGeneralMaximun;
			var rateEntertain = $('#grid-table').jqGrid('getRowData',rows[0]).rateEntertain;
			var rateEntertainTop = $('#grid-table').jqGrid('getRowData',rows[0]).rateEntertainTop;
			var rateEntertainMaximun = $('#grid-table').jqGrid('getRowData',rows[0]).rateEntertainMaximun;
			
			$("#agentRateLivelihood",window.parent.document).val(rateLivelihood);
			$("#agentRateGeneral",window.parent.document).val(rateGeneral);
			$("#agentRateGeneralTop",window.parent.document).val(rateGeneralTop);
			$("#agentRateGeneralMaximun",window.parent.document).val(cent2Yuan(rateGeneralMaximun));
			$("#agentRateEntertain",window.parent.document).val(rateEntertain);
			$("#agentRateEntertainTop",window.parent.document).val(rateEntertainTop);
			$("#agentRateEntertainMaximun",window.parent.document).val(cent2Yuan(rateEntertainMaximun));
			
			$("#agentId",window.parent.document).val(agentId);
			$("#agentName",window.parent.document).val(agentName);
			$("#rateLivelihood",window.parent.document).val(rateLivelihood);
			$("#rateGeneral",window.parent.document).val(rateGeneral);
			$("#rateGeneralTop",window.parent.document).val(rateGeneralTop);
			$("#rateGeneralMaximun",window.parent.document).val(cent2Yuan(rateGeneralMaximun));
			$("#rateEntertain",window.parent.document).val(rateEntertain);
			$("#rateEntertainTop",window.parent.document).val(rateEntertainTop);
			$("#rateEntertainMaximun",window.parent.document).val(cent2Yuan(rateEntertainMaximun));
			
			dialog.closeById('dlg-agentList');
		}
	</script>